<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <META name=viewport content="width=device-width, user-scalable=no, initial-scale=1">
    <LINK rel="stylesheet" href="__ROOT__/static/jquery.mobile-1.3.2.css">  
      <SCRIPT src="__ROOT__/static/jquery-1.10.2.js"></SCRIPT>
      <SCRIPT src="__ROOT__/static/jquery.mobile-1.3.2.js"></SCRIPT>      
      <title>单号扫描录入</title>
    </head>
    <body>
      <script type="text/javascript">
      document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('hideOptionMenu');
      });
      document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
        WeixinJSBridge.call('hideToolbar');
      });
      </script>
      <div data-role="page" id="infoPage">
        <div data-role="content">
          <UL data-role="listview" data-inset="true">
            <LI>
              <P>
                <div class="fieldcontain">
                  <label for="en">编码方式：</label>
                  <input name="en" id="exptype" value="" type="text">              
                </div>
                <div class="fieldcontain">
                  <label for="en">快递单号：</label>
                  <input name="en" id="expnum" value="" type="text">              
                </div>

              </P>
            </LI>
          </UL>
          <div id="myDIV" class="fieldcontain"></div>
          <center><div class="fieldcontain" style="width: 50%;">
            <input type="button" onclick='scancode()' value="扫描单号"/>
          </div></center>         
        </div>
        <div data-theme="a" data-role="footer" data-position="fixed">
          <h3>单号扫描示范</h3>
        </div>
      </div>
    </body>
    <script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
    <script>
    wx.config({
      debug: false,
      appId: '<?php echo $appId;?>',
      timestamp: <?php echo $timestamp;?>,
      nonceStr: '<?php echo $nonceStr;?>',
      signature: '<?php echo $signature;?>',
      jsApiList: ['scanQRCode']
    });



    function scancode(){
      wx.ready(function () {
        wx.scanQRCode({
    needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
    scanType: ["qrCode","barCode"], // 可以指定扫二维码还是一维码，默认二者都有
    success: function (res) {
      var result = res.resultStr;
      var arr=result.split(',');
      document.getElementById("exptype").value=arr[0];      
      document.getElementById("expnum").value=arr[1];
     // 当needResult 为 1 时，扫码返回的结果
   }
 });
    // 在这里调用 API
  });

    }

    </script>